#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>

#define TEMPE _IOR('T',0X1234,unsigned long)
#define HUMI _IOR('H',0X1235,unsigned long)

unsigned short iic_data_change(unsigned short data)//数据的高位和低位互换
{
	unsigned short temp=0;
	temp = data<<8;
	data = temp |(data>>8&0xff);
	return data;
}
       

int main()
{
	int fd,status=0;
	unsigned short read_data;
	double temperature;
	double humidity;
	fd = open("/dev/drv_i2c_si7600", O_RDWR);
	if(fd < 0)
	{
		printf("drv_drv_i2c_si7600 open err\r\n");
		exit(1);
	}
	while(1)
	{
		ioctl(fd, TEMPE, &read_data);
		read_data = iic_data_change(read_data);
		temperature = (175.72*read_data)/65536-46.85;
		printf("app:temperature=%f\r\n",temperature);
		sleep(1);
		if(status)
		{
			status=0;
		}
		else
		{
			status=1;
		}
	}
	close(fd);
}
